package com.acoffee.java2.service.Impl;

import com.acoffee.java2.pojo.Account;
import com.acoffee.java2.service.AccountService;
import com.acoffee.java2.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author acoffee
 * @create 2021-11-16 17:19
 */
@Service
public class PayServiceImpl implements PayService {

    @Autowired
    private AccountService accountService;


    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public void pay(Account account1, Account account2) {
        this.accountService.addAcount(account1);
        this.accountService.updateAccount(account2);
    }
}
